home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: writing to .exe file
- Date: 20 Feb 96 18:43:57 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.824841837@rscernix>
- References: <4g961o$gdr@ultra.sonic.net> <4gcg2n$6fd@kannews.ca.newbridge.com> <Pine.SOL.3.90.960220111544.24981F-100000@eddie>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <Pine.SOL.3.90.960220111544.24981F-100000@eddie> Darrell Grainger <a378grai@cdf.toronto.edu> writes:
-
- >On 20 Feb 1996, Glen Miner wrote:
- >
- >> >I would like to save data ( a string ) from one run of a (dos) program
- >> >to the next by writing it to the .exe file. does this sound doable?
- >>
- >> Yes. It's totally fine. Just append junk to the end of the exe file.
- >
- >It should be noted that this might not work on some operating systems. I
- >have seen systems that break the program into various parts based on
- >information in the program file. If there is extra data at the end of the
- >program the operating system will consider the program corrupt and fail to
- >load.
-
- And on some platforms you simply cannot open an executable file which
- is running in write or update mode:
-
- cnwgs1:/tmp 74> cat test.c
- #include <stdio.h>
-
- main(int argc, char **argv)
- {
- if (fopen(argv[0], "r+") == NULL) perror(argv[0]);
- else puts("It worked!");
- return 0;
- }
- cnwgs1:/tmp 75> cc test.c
- cnwgs1:/tmp 76> ./a.out
- ./a.out: Text file busy
-
- Of course, DOS isn't one of those platforms.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-